package com.ruoyi.system.service.impl;
import com.ruoyi.system.entity.JobImagesParam;
import com.ruoyi.system.mapper.JobImagesParamMapper;
import com.ruoyi.system.service.JobImagesParamService;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import javax.annotation.Resource;

/**
 * 签名字段(JobImagesParam)表服务实现类
 *
 * @author makejava
 * @since 2023-04-27 13:45:48
 */
@Service("jobImagesParamService")
public class JobImagesParamServiceImpl implements JobImagesParamService {
    @Resource
    private JobImagesParamMapper jobImagesParamDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public JobImagesParam queryById(Integer id) {
        return this.jobImagesParamDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param jobImagesParam 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<JobImagesParam> queryByPage(JobImagesParam jobImagesParam, PageRequest pageRequest) {
        long total = this.jobImagesParamDao.count(jobImagesParam);
        return new PageImpl<>(this.jobImagesParamDao.queryAllByLimit(jobImagesParam, pageRequest), pageRequest, total);
    }

    /**
     * 新增数据
     *
     * @param jobImagesParam 实例对象
     * @return 实例对象
     */
    @Override
    public JobImagesParam insert(JobImagesParam jobImagesParam) {
        this.jobImagesParamDao.insert(jobImagesParam);
        return jobImagesParam;
    }

    /**
     * 修改数据
     *
     * @param jobImagesParam 实例对象
     * @return 实例对象
     */
    @Override
    public JobImagesParam update(JobImagesParam jobImagesParam) {
        this.jobImagesParamDao.update(jobImagesParam);
        return this.queryById(jobImagesParam.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.jobImagesParamDao.deleteById(id) > 0;
    }
}
